<!DOCTYPE html>
<html class="no-js" lang="zxx">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=edge" />
    <title>Manage Jobs - JobGrids Job Portal HTML Template.</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.svg" />
    <!-- Place favicon.ico in the root directory -->

    <!-- Web Font -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
        rel="stylesheet">

    <!-- ========================= CSS here ========================= -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
    <link rel="stylesheet" href="assets/css/LineIcons.2.0.css" />
    <link rel="stylesheet" href="assets/css/animate.css" />
    <link rel="stylesheet" href="assets/css/tiny-slider.css" />
    <link rel="stylesheet" href="assets/css/glightbox.min.css" />
    <link rel="stylesheet" href="assets/css/main.css" />

</head>

<body>
    <!--[if lte IE 9]>
      <p class="browserupgrade">
        You are using an <strong>outdated</strong> browser. Please
        <a href="https://browsehappy.com/">upgrade your browser</a> to improve
        your experience and security.
      </p>
    <![endif]-->

    <div id="loading-area"></div>

    <!-- Start Header Area -->
    <header class="header">
      <div class="navbar-area">
        <div class="container">

          <div class="row align-items-center">

            <div class="col-lg-12">
              <nav class="navbar navbar-expand-lg">
                <a class="navbar-brand logo" href="index-hr.html">
                  <img class="logo1" src="assets/images/logo/logo.svg" alt="Logo" />
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse"
                        data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                  <span class="toggler-icon"></span>
                  <span class="toggler-icon"></span>
                  <span class="toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse sub-menu-bar" id="navbarSupportedContent">
                  <ul id="nav" class="navbar-nav ml-auto">
                    <li class="nav-item">
                      <a  href="index-hr.html">主页</a>
                    </li>



                    <li class="nav-item">
                      <a  href="browse-jobs.html">职位搜索</a>
                    </li>


                    <li class="nav-item "><a href="#" class="active">职位管理 </a>
                      <ul class="sub-menu ">
                        <li><a  href="post-job.html">发布职位</a></li>
                        <li><a class="active" href="manage-jobs.html">职位查看与编辑</a></li>
                        <li><a  href="have-manage-resumes.html">已处理申请</a></li>
                        <li><a  href="manage-resumes.html">待处理申请</a></li>

                      </ul>
                    </li>



                    <li class="nav-item">
                      <a href="blog-grid-sidebar.html">论坛</a></li>
                    </li>

                    <li class="nav-item"><a href="contact.html">联系我们 </a> </li>


                    <li class="nav-item"><a href="#">其他</a>
                      <ul class="sub-menu">
                        <!-- <li><a href="index.html" onclick="logout()">Log Out</a></li> -->
                        <li><a onclick="checkloginuser()">Personal Info</a></li>
                        <li><a href="about-us.html" onclick="addtoken()">About Us</a></li>
                        <li><a href="job-list.html">Job List</a></li>
                        <li><a href="job-details.html">Job Details</a></li>
                        <li><a href="resume.html">Resume Page</a></li>
                        <li><a href="privacy-policy.html">Privacy Policy</a></li>
                        <li><a href="faq.html">Faq</a></li>
                        <li><a href="pricing.html">Our Pricing</a></li>
                        <li><a href="404.html">404 Error</a></li>
                        <li><a href="mail-success.html">Mail Success</a></li>
                      </ul>
                    </li>

                    <li class="nav-item">
                      <a href="#">个人中心</a>
                      <ul class="sub-menu">
                        <li><a href="showhrinfo.html">信息编辑</a></li>

                        <li><a href="job-alerts.html">消息提醒</a></li>
                        <li><a href="manage-blog.html">管理博客</a></li>
                      </ul>
                    </li>
                    <li class="nav-item login">

                      <a href="showhrinfo.html" id="shownameid" >
                      </a>
                      <ul class="sub-menu">
                        <li><a href="index.html" onclick="logout()">退出登录</a></li>
                      </ul>
                    </li>
                  </ul>
                </div>
                <!-- navbar collapse -->
                <!--登录显示用户名的地方，点击进入到个人中心界面-->



              </nav>
              <!-- navbar -->
            </div>
          </div>
          <!-- row -->
        </div>
        <!-- container -->
      </div>
      <!-- navbar area -->
    </header>
    <!-- End Header Area -->


    <!-- Main Content Start -->
    <div class="manage-jobs section">
        <div class="container">
            <div class="alerts-inner">
                <div class="row ">
                    <!-- Start Main Content -->
                    <div class="col-lg-4 col-12">
                        <div class="dashbord-sidebar">
                            <ul>
                                <li class="heading">职位管理</li>
                                <!-- <li><a href="resume.html"><i class="lni lni-clipboard"></i> My Resume</a></li> -->
                                <li><a  href="post-job.html"><i class="lni lni-briefcase"></i> 发布职位</a></li>

                                <li><a class="active" href="manage-jobs.html"><i class="lni lni-briefcase"></i> 职位查看与编辑</a></li>
                                <li><a href="have-manage-resumes.html"><i class="lni lni-upload"></i> 已处理申请</a></li>
                                <li><a href="manage-resumes.html"><i class="lni lni-envelope"></i> 待处理申请</a></li>
                                <!-- <li><a href="hr_manage-applications.html"><i class="lni lni-bookmark"></i> 职位查看 </a></li> -->
                                <li><a href="notifications.html"><i class="lni lni-alarm"></i> 消息提醒 <span
                                            class="notifi">5</span></a></li>

                                <!-- <li><a href="change-password.html"><i class="lni lni-lock"></i> Change Password</a></li>-->
                            </ul>
                        </div>
                    </div>
                    <!-- End Main Content -->
                    <div class="col-lg-8 col-12">
                        <div class="job-items">
                            <div class="manage-list">
                                <div class="row ">
                                    <div class="col-lg-2 col-md-2 col-12">
                                        <p>   职位</p>
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-12">
                                        <p> 已通过人数</p>
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-12">
                                        <p> 已拒绝人数</p>
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-12">
                                        <p> 未处理人数</p>
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-12">
                                        <p> 总人数</p>
                                    </div>
                                    <div class="col-lg-2 col-md-2 col-12">
                                        <p>   操作</p>
                                    </div>
                                </div>
                            </div>
                            <div class="manage-content">
                                <div class="row align-items-center justify-content-center job-list">



                                </div>
                            </div>

                        </div>
                        <!-- Pagination -->
                        <div class="pagination left pagination-md-center">
                            <ul class="pagination-list">
                                <li><a href="#"><i class="lni lni-arrow-left"></i></a></li>
                                <li class="active"><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#"><i class="lni lni-arrow-right"></i></a></li>
                            </ul>
                        </div>
                        <!-- End Pagination -->
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Main Content end -->

    <!-- Login Modal -->
    <div class="modal fade form-modal" id="login" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog max-width-px-840 position-relative">
            <button type="button"
                class="circle-32 btn-reset bg-white pos-abs-tr mt-md-n6 mr-lg-n6 focus-reset z-index-supper"
                data-dismiss="modal"><i class="lni lni-close"></i></button>
            <div class="login-modal-main">
                <div class="row no-gutters">
                    <div class="col-12">
                        <div class="row">
                            <div class="heading">
                                <h3>Login From Here</h3>
                                <p>Log in to continue your account <br> and explore new jobs.</p>
                            </div>
                            <div class="social-login">
                                <ul>
                                    <li><a class="linkedin" href="#"><i class="lni lni-linkedin-original"></i> Log in
                                            with LinkedIn</a></li>
                                    <li><a class="google" href="#"><i class="lni lni-google"></i> Log in with
                                            Google</a></li>
                                    <li><a class="facebook" href="#"><i class="lni lni-facebook-original"></i> Log in
                                            with Facebook</a></li>
                                </ul>
                            </div>
                            <div class="or-devider">
                                <span>Or</span>
                            </div>
                            <form action="/">
                                <div class="form-group">
                                    <label for="email" class="label">E-mail</label>
                                    <input type="email" class="form-control" placeholder="example@gmail.com" id="email">
                                </div>
                                <div class="form-group">
                                    <label for="password" class="label">Password</label>
                                    <div class="position-relative">
                                        <input type="password" class="form-control" id="password"
                                            placeholder="Enter password">
                                    </div>
                                </div>
                                <div class="form-group d-flex flex-wrap justify-content-between">
                                    <!-- Default checkbox -->
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" value=""
                                            id="flexCheckDefault" />
                                        <label class="form-check-label" for="flexCheckDefault">Remember password</label>
                                    </div>
                                    <a href="" class="font-size-3 text-dodger line-height-reset">Forget Password</a>
                                </div>
                                <div class="form-group mb-8 button">
                                    <button class="btn ">Log in
                                    </button>
                                </div>
                                <p class="text-center create-new-account">Don’t have an account? <a href="#">Create a free account</a></p>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End Login Modal -->

    <!-- Signup Modal -->
    <div class="modal fade form-modal" id="signup" tabindex="-1" aria-hidden="true">
        <div class="modal-dialog max-width-px-840 position-relative">
            <button type="button"
                class="circle-32 btn-reset bg-white pos-abs-tr mt-md-n6 mr-lg-n6 focus-reset z-index-supper"
                data-dismiss="modal"><i class="lni lni-close"></i></button>
            <div class="login-modal-main">
                <div class="row no-gutters">
                    <div class="col-12">
                        <div class="row">
                            <div class="heading">
                                <h3>Create a free Account <br> Today</h3>
                                <p>Create your account to continue <br> and explore new jobs.</p>
                            </div>
                            <div class="social-login">
                                <ul>
                                    <li><a class="linkedin" href="#"><i class="lni lni-linkedin-original"></i> Import from LinkedIn</a></li>
                                    <li><a class="google" href="#"><i class="lni lni-google"></i> Import from
                                            Google</a></li>
                                    <li><a class="facebook" href="#"><i class="lni lni-facebook-original"></i> Import from Facebook</a></li>
                                </ul>
                            </div>
                            <div class="or-devider">
                                <span>Or</span>
                            </div>
                            <form action="/">
                                <div class="form-group">
                                    <label for="email" class="label">E-mail</label>
                                    <input type="email" class="form-control" placeholder="example@gmail.com">
                                </div>
                                <div class="form-group">
                                    <label for="password" class="label">Password</label>
                                    <div class="position-relative">
                                        <input type="password" class="form-control"
                                            placeholder="Enter password">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="password" class="label">Confirm Password</label>
                                    <div class="position-relative">
                                        <input type="password" class="form-control"
                                            placeholder="Enter password">
                                    </div>
                                </div>
                                <div class="form-group d-flex flex-wrap justify-content-between">
                                    <!-- Default checkbox -->
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" value="">
                                        <label class="form-check-label" for="flexCheckDefault">Agree to the <a
                                                href="#">Terms & Conditions</a></label>
                                    </div>
                                </div>
                                <div class="form-group mb-8 button">
                                    <button class="btn ">Sign Up
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End Signup Modal -->

                        <!-- Start Footer Area -->
<footer class="footer">
        <div class="footer-bottom">
            <div class="container">
                <div class="inner">
                    <div class="row">
                        <div class="col-lg-6 col-md-6 col-12">
                            <div class="left">
                                <p><a target="_blank" >软件工程大作业</a></p>
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6 col-12">
                            <div class="right">
                                <ul>
                                    <li><a href="privacy-policy.html">用户手册</a></li>
                                    <li><a href="#">项目文档</a></li>
                                    <li><a href="https://gitee.com/Yuan-Wi/software-engineering-team/tree/master/">gitee</a></li>
                                    <li><a href="contact.html">联系我们</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- End Footer Middle -->
    </footer>
    <!--/ End Footer Area -->

    <!-- ========================= scroll-top ========================= -->
    <a href="#" class="scroll-top btn-hover">
        <i class="lni lni-chevron-up"></i>
    </a>

    <!-- ========================= JS here ========================= -->
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>

    <script src="assets/js/wow.min.js"></script>
    <script src="assets/js/tiny-slider.js"></script>
    <script src="assets/js/glightbox.min.js"></script>
    <script src="assets/js/main.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
<script>
  //================注册登录相关
   //像后端传本地浏览器保存的token（当前登录用户）点击首页跳转的页面
function checkloginuser(){
 //window.location.reload();

$.ajax({
url: "http://localhost:8080/mycheckloginuser",
type: "GET",
data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
success: function(result){
// alert(result.code);
 if(result.code==200){
   if(result.msg=="hrlogin"){

   location.href="http://localhost/static/html/showhrinfo.html";
   }
   else if(result.msg=="employeelogin"){window.location.href="http://localhost/static/html/showseekerinfo.html";}
 }
 else {
   alert(result.code+result.msg);
   }
},
error: function(){
alert("请刷新重试");
},
});

};
//其他业务请求从本地浏览器中存的token获取加入请求头

function logout(){
window.localStorage.removeItem('user');
location.href="http://localhost/static/html/index.html";
};
var loginuserinfo;//当前登录用户的角色和id
/*解析token*/
function sparsetoken(){
var token;
$(function(){
token = window.localStorage.getItem("user");//这可以得到当前登录用户的token
alert("user="+token);
alert(window.location.href);
//data.data.normal_login_token为发送Ajax获取到的token信息
var strings = token.split(".");//通过split()方法将token转为字符串数组
//取strings[1]数组中的第二个字符进行解析
var userinfo = JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, "+").replace(/_/g, "/")))));
loginuserinfo = userinfo;//赋给全局变量
//然后可以拿到解析后的数据，可以console.log()打印下，roleid是在表中的id，loginrole=hrlogin或seekerlogin
alert(userinfo.roleid+userinfo.loginrole+'userinfo');

});

};


//===========最初需要完成名字的显示
$(document).ready(function(){


    /*   alert("新方法");*/
       $.ajax({
url: "http://localhost:8080/mylogingetusername",
type: "GET",
data: {token : window.localStorage.getItem("user")?window.localStorage.getItem("user"):"notoken"},
success: function(result){
// alert(result.code);
 if(result.code==200){
 alert(result.msg);
 document.getElementById('shownameid').textContent = "欢迎"+result.msg+"登录";
 }
 else {
   alert(result.code+result.msg);
   }
},
error: function(){
alert("请刷新重试");
},
});
   });


   //页面显示
   $(document).ready(function(){
        token = window.localStorage.getItem("user");//这可以得到当前登录用户的token
        //alert("user="+token);
        //alert(window.location.href);
        //data.data.normal_login_token为发送Ajax获取到的token信息
        var strings = token.split(".");//通过split()方法将token转为字符串数组
        //取strings[1]数组中的第二个字符进行解析
        var userinfo = JSON.parse(decodeURIComponent(escape(window.atob(strings[1].replace(/-/g, "+").replace(/_/g, "/")))));
        //loginuserinfo = userinfo;//赋给全局变量
        //然后可以拿到解析后的数据，可以console.log()打印下，roleid是在表中的id，loginrole=hrlogin或seekerlogin
        alert(userinfo.roleid+userinfo.loginrole+'userinfo');

        //var hrIdStr = $('[name=hrid]').val();
        //var hrId = parseInt(hrIdStr, 10);  // 将字符串转换为整数
        var hrId =userinfo.roleid;
        alert(hrId+'hrId');

        if (isNaN(hrId)) {
          alert('请输入有效的HR ID');
          return;
        }

        var data = {
          hrId: hrId
        };


        $.ajax({
            url: 'http://localhost:8080/system/job/listByhrid',
            type: 'get',
            data: data,
            dataType: 'json',
            headers: {
                'X-Requested-With': 'XMLHttpRequest'
            },
            success: function (res) {
                console.log(res);
                console.log("response ok for seekjobby hrid");
                var html = '';
                var promises = [];
                var results = {}; // 存储每个 jobId 的结果

                res.rows.forEach(function (item) {
                    // 创建每个 job 的初始 HTML
                    var jobId = item.jobId;
                    results[jobId] = {
                        initialHtml: `
                            <div class="col-lg-2 col-md-2 col-12" id="job-${jobId}">
                                <h3><a href="job-details.html">${item.jobName}</a></h3>
                            </div>
                        `,
                        countsHtml: {
                            result1: '<div class="col-lg-2 col-md-2 col-12" id="result1-placeholder-' + jobId + '"></div>',
                            result2: '<div class="col-lg-2 col-md-2 col-12" id="result2-placeholder-' + jobId + '"></div>',
                            result0: '<div class="col-lg-2 col-md-2 col-12" id="result0-placeholder-' + jobId + '"></div>',
                            resultAny: '<div class="col-lg-2 col-md-2 col-12" id="resultAny-placeholder-' + jobId + '"></div>'
                        }
                    };

                    // 函数来创建一个 AJAX 请求并返回一个 Promise
                    function createAjaxPromise(data, jobId, resultKey) {
                        return $.ajax({
                            url: 'http://localhost:8080/system/job_seeker_relation/count',
                            type: 'get',
                            data: data,
                            dataType: 'json',
                            headers: {
                                'X-Requested-With': 'XMLHttpRequest'
                            }
                        }).then(function (countRes) {
                            console.log("jobid" + jobId);
                            console.log("countRes" + countRes);
                            console.log("response ok for job seeker relation count");

                            // 更新对应 jobId 的 countsHtml
                            results[jobId].countsHtml[resultKey] = `
                                <div class="col-lg-2 col-md-2 col-12">
                                    <p><span class="time">${countRes}</span></p>
                                </div>
                            `;
                        });
                    }

                    // 创建并添加多个 Promise 到数组
                    promises.push(createAjaxPromise({ jobId: jobId, result: 1 }, jobId, 'result1'));
                    promises.push(createAjaxPromise({ jobId: jobId, result: 2 }, jobId, 'result2'));
                    promises.push(createAjaxPromise({ jobId: jobId, result: 0 }, jobId, 'result0'));
                    promises.push(createAjaxPromise({ jobId: jobId }, jobId, 'resultAny'));
                });

                // 等待所有 Promise 完成后更新页面
                Promise.all(promises).then(function () {
                    // 构建最终的 HTML
                    for (var jobId in results) {
                      //alert(jobId);
                        var countsHtml = Object.values(results[jobId].countsHtml).join('');
                       // alert(countsHtml);
                        html += results[jobId].initialHtml + countsHtml + `
                            <div class="col-lg-2 col-md-2 col-12">
                                <div class="action-btn">
                                    <a href="changejobinfo.html?jobId=${jobId}">编辑职位</a>

                                </div>
                            </div>
                            <br>
                            <br>
                            <br>
                            <br>
                        `;
                      //alert(html);
                    }
                    $('.job-list').html(html);
                });
            }
        });

           });
</script>
</body>

</html>
